package nl.saxion.saktiehuis.dao;

import java.util.List;

import nl.saxion.saktiehuis.model.Klant;
import nl.saxion.saktiehuis.util.AbstractDaoImpl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

@Repository
public class KlantDaoImpl extends AbstractDaoImpl<Klant> implements KlantDao {

	@Override
	public Klant getKlant(String naam) {
		Criteria criteria = getSession().createCriteria(Klant.class);
		criteria.add(Restrictions.eq("naam", naam));
		return (Klant) criteria.uniqueResult();
	}

	@Override
	public List<Klant> getAlleKlanten() {
		Criteria criteria = getSession().createCriteria(Klant.class);
		return criteria.list();
	}

}
